<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
id=request.QueryString("edit")
if id<>"" then
	  set rsm=server.CreateObject("adodb.recordset")
	  sql="select * from YServiceCost where id="&id&""
	  rsm.open sql,conn,1,3
	  if not rsm.eof then
          Startmoney=rsm("Startmoney")
		  Endmoney=rsm("Endmoney")
		  rate=rsm("rate")
	  rsm.close
	  set rsm=nothing
	  end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div class="main">
  <div class="main-title">按照订单金额设置叠加服务费</div>
  <div class="main-content">
  <%if id<>"" then%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6">
    <form name="form" method="post" action="">
    <input name="StartMoney" type="text" class="input" id="StartMoney" style="width:50px" value="<%=StartMoney%>" maxlength="50" />
    -
    <input name="EndMoney" type="text" class="input" id="EndMoney" style="width:50px" value="<%=EndMoney%>" maxlength="50" />
    =
    <input name="rate" type="text" class="input" id="rate" style="width:50px" value="<%=rate%>" maxlength="50" />%
    <input name="id" type="hidden" id="id" value="<%=id%>" />
<input type="submit" name="button" id="button" value="保存" />
<a href="javascript:;" onClick="javascript:history.back(-1);">返回</a>
    </form>
    </td>
    </tr>
    </table>
  <%else%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6">
    <form name="form" method="post" action="">
    <input name="StartMoney" type="text" class="input" style="width:80px" id="StartMoney" value="起始金额日元" maxlength="50" />
    -
    <input name="EndMoney" type="text" class="input" style="width:80px" id="EndMoney" value="最大金额日元" maxlength="50" />
    =
    <input name="rate" type="text" class="input" style="width:80px" id="rate" value="收费金额比率" maxlength="50" />%
    
    <input type="submit" name="button" id="button" value="添加" />
    </form>
    </td>
    </tr>
    </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td bgcolor="#FFFFFF"><strong>起始金额</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>最大金额</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>收费</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>删除</strong></td>
    </tr>
     <%
					  set rsu=server.CreateObject("adodb.recordset")
					  sql="select * from YServiceCost"
					  rsu.open sql,conn,1,3
					  if not rsu.eof then
					  do while not rsu.eof
					  %>
  <tr>
    <td bgcolor="#FFFFFF"><%=FormatNumber(rsu("StartMoney"),2,-1)%></td>
    <td align="center" bgcolor="#FFFFFF"><%=FormatNumber(rsu("EndMoney"),2,-1)%></td>
    <td align="center" bgcolor="#FFFFFF"><%=rsu("rate")%>%</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?edit=<%=rsu("id")%>">修改</a></td>
    <td align="center" bgcolor="#FFFFFF"><a href="?del=<%=rsu("id")%>">删除</a></td>
    </tr>
    <%
					  rsu.movenext
					  loop
					  rsu.close
					  set rsu=nothing
					  end if		 
					  %>
  
  </table>
  <%end if%>
</div>
</div>
</body>
</html>
<%
StartMoney=request.Form("StartMoney")
EndMoney=request.Form("EndMoney")
rate=request.Form("rate")
if isnumeric(StartMoney)=false then StartMoney=0
if isnumeric(EndMoney)=false then EndMoney=0
if isnumeric(rate)=false then rate=0
if request.Form("button")="添加" then

	set rsu=server.createobject("adodb.recordset")
	sql="select * from YServiceCost"
	rsu.open sql,conn,1,3
	rsu.addnew
	rsu("StartMoney")=StartMoney
	rsu("EndMoney")=EndMoney
	rsu("rate")=rate
	rsu.update
	response.write"<script language=JavaScript>{window.alert('添加成功！');window.location.href='view.asp';}</script>"
	rsu.close
	set rsu=nothing
	
elseif request.Form("button")="保存" then

	set rsu=server.createobject("adodb.recordset")
	sql="select * from YServiceCost where id="&id&""
	rsu.open sql,conn,1,3
	rsu("StartMoney")=StartMoney
	rsu("EndMoney")=EndMoney
	rsu("rate")=rate
	rsu.update
	response.write"<script language=JavaScript>{window.alert('保存成功！');window.location.href='view.asp';}</script>"
	rsu.close
	set rsu=nothing

elseif request.QueryString("del")<>"" then
    conn.execute("delete from YServiceCost where id="&request.QueryString("del")&"")
	response.Redirect "view.asp"
end if
%>